package com.nineclock.document.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nineclock.document.pojo.DocFile;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DocFileMapper extends BaseMapper<DocFile> {

    /**
     * 查询指定目录下，当前登录用户协作的文件列表
     * @param companyId
     * @param folderId
     * @param companyUserId
     * @return
     */
    @Select("select * from doc_file f where f.company_id = #{companyId} and f.folder_id = #{folderId} and f.`status` = 1 and " +
            " f.id in (select file_id from doc_collaborations where collaboration_id = #{companyUserId})")
    public List<DocFile> selectFileListByCollaboration(@Param("companyId") Long companyId, @Param("folderId") Long folderId,
                                                       @Param("companyUserId") Long companyUserId);
}
